package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.HotSearch;
import com.micro.modual.extension.HotSearchExtension;
import com.micro.modual.mapper.HotSearchMapper;
import com.micro.modual.model.bo.hotsearch.HotSearchBO;
import com.micro.modual.service.HotSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>热搜记录表(选用)  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("hotSearchService")
public class HotSearchServiceImpl extends AbstractBasicsServiceImpl<HotSearch,Long> implements HotSearchService {

    @Autowired
    private HotSearchMapper hotSearchMapper;

    /**
     * <h2>新增热搜记录表(选用)详情</h2>
     * @param hotSearchBO {@link HotSearchBO} 热搜记录表(选用) 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addHotSearch(HotSearchBO hotSearchBO) {
        HotSearch hotSearch = HotSearchExtension.converAddHotSearch(hotSearchBO);
        hotSearchMapper.insertSelective(hotSearch);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改热搜记录表(选用)详情</h2>
     * @param hotSearchBO  {@link HotSearchBO} 热搜记录表(选用) 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editHotSearch(HotSearchBO hotSearchBO) {
        HotSearch hotSearch = HotSearchExtension.converEditHotSearch(hotSearchBO);
        hotSearchMapper.updateByPrimaryKeySelective(hotSearch);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除热搜记录表(选用)信息</h2>
     * @param id  热搜记录表(选用) 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteHotSearch(Long id) {
        hotSearchMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
